 {

        var o = require("../UISoundManager.js");
        cc.Class({
            extends: cc.Component,
            properties: {
                _dataResult: null
            },
            onLoad: function () {
                this._btnTitle = Global.utils.searchComp(this.node, "title", cc.Label), this._kindId = Global.utils.searchComp(this.node, "kindId", cc.Label),
                    this._taskId = Global.utils.searchComp(this.node, "taskId", cc.Label), this._btnTitleSp = Global.utils.searchComp(this.node, "titleSp", cc.Sprite),
                    this._receivedSp = Global.utils.searchComp(this.node, "receivedSp", cc.Sprite),
                    this.tipProgess = Global.utils.searchComp(this.node, "progressBar", cc.ProgressBar),
                    Global.notificationCenter.on(Global.eventName.MSG_REWARD_INFO, this.showFreeGiveReward.bind(this), this),
                    Global.notificationCenter.on(Global.eventName.GAME_TASKS, this.onGameTasks.bind(this), this),
                    this.defaultPlayMode = Global.config.playModel.XUELIU;
            },
            start: function () {
            },
            onDestroy: function () {
                Global.notificationCenter.offAll(this);
            },
            onGameTasks: function (e) {
                this.shouldGetReward = !1, this.isClick && (this.isClick = !1, this.shouldGetReward = !0);
            },
            showFreeGiveReward: function (e) {
                if (this.shouldGetReward && "recieve" == e.action) if (e.tip) Global.utils.showNodeCommon(e.tip, 2); else {
                    var t = function () {
                        if (console.log("领取成功回调。。。。。", this._dataResult), this._dataResult) {
                            var e = this._dataResult.playMode, t = Global.roomInfoModel.getRoomId();
                            Global.msgHandler.requestQuickStart(e, t);
                        }
                    }.bind(this);
                    e = {
                        reward: e.deltaChip,
                        name: "金币",
                        type: "freegive"
                    };
                    Global.UIPopupManager.addPopup("PopupPanel/Panel_shareGroup_Reward", function (n) {
                        n.getComponent("shareGroup_RewardPanel").setData(e, t), Global.spriteAtlas.setSpriteFrame(n.getComponent("shareGroup_RewardPanel").rewardSp, "Texture/Rewards", "WP_3");
                    });
                }
            },
            bindData: function (e, t) {
                null != e ? (this._taskData = e, this._completeData = t, this.refresh(e, t)) : cc.error("ShopSelectItem", "bindData data = null");
            },
            randomCal: function () {
                var e = function (e, t) {
                    for (var n = 0, o = 0, i = Math.random(), a = t.length - 1; a >= 0; a--) n += t[a];
                    i *= n;
                    for (var r = t.length - 1; r >= 0; r--) if (i <= (o += t[r])) return e[r];
                    return null;
                }, t = ["1000", "0"], n = [.15, .85];
                return console.log("randomCal", e(t, n)), e(t, n);
            },
            onDoubleClick: function () {
                this.isClick = !0;
                var e = this.randomCal();
                if (e) switch (e) {
                    case "1000":
                        var t = this._taskId.string;
                        Global.notificationCenter.emit(Global.eventName.MSG_SHOW_REWARD_RANDOM, t);
                }
                var n = this;
                Global.utils.showViewAd(Global.config.adTaskUnitId, function () {
                    var e = 0, t = 0;
                    n._taskId && cc.isValid(n._taskId) && (e = n._taskId.string), n._kindId && cc.isValid(n._kindId) && (t = n._kindId.string),
                        n.scheduleOnce(function () {
                            var n = {
                                taskId: e,
                                kindId: t,
                                type: 1
                            };
                            Global.msgHandler.requestGetTaskReward(n);
                        }, .2);
                }, function () {
                    Global.utils.showNodeCommon("您在播放中途退出，无法领取游戏奖励", 3);
                }), o.playEffect("select");
            },
            onClick: function () {
                switch (this.isClick = !0, this._btnTitle.string) {
                    case Global.config.taskState.RECEIVED:
                        return;

                    case Global.config.taskState.RECEIVE:
                        var e = this.randomCal();
                        if (console.log("NodeTaskItem onClick", e), e) switch (e) {
                            case "1000":
                                var t = this._taskId.string;
                                Global.notificationCenter.emit(Global.eventName.MSG_SHOW_REWARD_RANDOM, t);
                        }
                        var n = {
                            taskId: this._taskId.string,
                            kindId: this._kindId.string
                        };
                        Global.msgHandler.requestGetTaskReward(n);
                        break;

                    case Global.config.taskState.TOFINISH:
                        if ("100053" == this._kindId.string || "100054" == this._kindId.string || "100056" == this._kindId.string) this._dataResult = {
                            playMode: this.defaultPlayMode,
                            gameId: Global.config.GAMEID_NORMAL,
                            type: "xueliu"
                        }, Global.notificationCenter.emit(Global.eventName.MSG_DO_QUICK_START, this._dataResult); else if ("100055" == this._kindId.string) {
                            var i = {
                                share_type: Global.config.sharePointId.hallShare
                            };
                            tywx.PropagateInterface.getWeightShareConfigInfoByTypeWithShare(i, null, function () {
                                Global.msgHandler.requestTaskShareSuccess();
                            });
                        } else "100058" == this._kindId.string ? (this._dataResult = {
                            playMode: Global.config.playModel.ERREN,
                            gameId: Global.config.GAMEID_ERREN,
                            type: "erren"
                        }, Global.notificationCenter.emit(Global.eventName.MSG_DO_QUICK_START, this._dataResult)) : "100059" == this._kindId.string && (this._dataResult = {
                            playMode: Global.config.playModel.ERRENQUICK,
                            gameId: Global.config.GAMEID_ERRENQUICK,
                            type: "erren_quick"
                        }, Global.notificationCenter.emit(Global.eventName.MSG_DO_QUICK_START, this._dataResult));
                }
                o.playEffect("select");
            },
            refresh: function (e, t) {
                var n = Global.utils.searchComp(this.node, "title1", cc.Label),
                    o = Global.utils.searchComp(this.node, "progressNum", cc.Label),
                    i = Global.utils.searchComp(this.node, "reward_num", cc.Label),
                    a = Global.utils.searchComp(this.node, "icon", cc.Sprite),
                    r = Global.utils.searchComp(this.node, "button", cc.Sprite),
                    s = Global.utils.searchNode(this.node, "videoBtn"),
                    l = Global.utils.searchNode(this.node, "Normalline");
                if (l.active = !1, s.active = !1, n.string = e.desc, this._kindId.string = e.kindId,
                null != t) switch (o.string = t[2] + "/" + e.progressMax, this.tipProgess.progress = t[2] / e.progressMax,
                    Global.spriteAtlas.setSpriteFrame(a, "Texture/task", e.pic), i.string = "x" + e.rewardContent.items[0].count,
                    this._taskId.string = t[0], t[3]) {
                    case 0:
                        this._btnTitle.string = Global.config.taskState.TOFINISH, Global.spriteAtlas.setSpriteFrame(this._btnTitleSp, "Texture/task", "RW_quwancheng"),
                            Global.spriteAtlas.setSpriteFrame(r, "Texture/common", "TY_ICON1");
                        break;

                    case 1:
                        this._btnTitle.string = Global.config.taskState.RECEIVE, Global.spriteAtlas.setSpriteFrame(this._btnTitleSp, "Texture/task", "RW_linqu"),
                            Global.spriteAtlas.setSpriteFrame(r, "Texture/shareGetDiamond", "TY_ICON3"), r.node.active = !1,
                            l.active = !0, s.active = !0;
                        break;

                    case 2:
                        this._btnTitle.string = Global.config.taskState.RECEIVED, this._btnTitle.node.parent.active = !1,
                            this._receivedSp.node.active = !0, l.active = !1, s.active = !1;
                }
            },
            update: function (e) {
            }
        })
    }